package edu.fim.data.dao;

import java.io.Serializable;
import java.util.List;

import edu.fim.data.dao.exception.DAOException;


/**
 * The generic interface for Data Access Objects (DAOs). A DAO is responsible
 * for communicating with the database directly, and thus, encapsulates a way to
 * reach the database. In general, for every entity in the database, there is a
 * DAO.
 * 
 * @author Itikawa
 * 
 * @param <T>: The entity's Type.
 */
public interface DAO<T extends Serializable, K extends Serializable> {

	void persist(T entity) throws DAOException;
	
	void update(T entity) throws DAOException;

	void delete(T entity) throws DAOException;

	T findById(K id) throws DAOException;
	
	List<T> findAll() throws DAOException;
	
	T findEntityByField(String field, Object value) throws DAOException;
	
	List<T> findEntitiesByField(String field, Object value) throws DAOException;
	
	T findEntityByFields(String[] field, Object[] value) throws DAOException;
	
	List<T> findEntitiesByFields(String[] field, Object[] value) throws DAOException;
	
	T findEntityByQuery(String sql);
	
	List<T> findEntitiesByQuery(String sql);
}